﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GameTypes
{

    public class ObjectManager
    {

        private List<GameObject> Objects = new List<GameObject>();
        private Dictionary<int, GameObject> ObjectsById = new Dictionary<int, GameObject>();

        public List<GameObject> getObjects()
        {
            return this.Objects;
        }

        public void add(GameObject Object)
        {
            this.Objects.Add(Object);
            this.ObjectsById.Add(Object.getId(), Object);
        }

        public GameObject get(int id)
        {
            return this.ObjectsById[id];
        }

        public void remove(GameObject Object)
        {
            if (Object == null) return;
            this.Objects.Remove(Object);
            this.ObjectsById.Remove(Object.getId());
        }

        public void remove(int id)
        {
            if (!this.ObjectsById.ContainsKey(id)) return;
            this.Objects.Remove(this.ObjectsById[id]);
            this.ObjectsById.Remove(id);
        }

    }

}
